#include<iostream>
#include<string>
using namespace std;
string s;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> s;
		int ans = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] >= '0' && s[i] <= '9') {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}